import { ApiProperty } from '@nestjs/swagger';
import { CatalogEntity } from '../catalog.entity';

export class CatalogResponseDto {
  @ApiProperty({ description: '目录ID', example: 1 })
  id: number;

  @ApiProperty({ description: '目录名称', example: '健康知识' })
  name: string;

  @ApiProperty({ description: '目录编码', example: 'health_knowledge', required: false })
  code?: string;

  @ApiProperty({ description: '目录描述', example: '健康知识相关内容', required: false })
  description?: string;

  @ApiProperty({ description: '排序值', example: 1 })
  sortOrder: number;

  @ApiProperty({ description: '是否启用', example: 1 })
  isActive: number;

  @ApiProperty({ description: '推送开始时间', example: '2024-01-01', required: false })
  pushStartTime?: Date;

  @ApiProperty({ description: '推送结束时间', example: '2024-12-31', required: false })
  pushEndTime?: Date;

  @ApiProperty({ description: '关联的分类ID', example: 1, required: false })
  categoryId?: number;

  @ApiProperty({ description: '创建时间', example: '2024-01-01T00:00:00.000Z' })
  createdAt: Date;

  @ApiProperty({ description: '更新时间', example: '2024-01-01T00:00:00.000Z' })
  updatedAt: Date;

  constructor(catalog: CatalogEntity) {
    this.id = catalog.id;
    this.name = catalog.name;
    this.code = catalog.code;
    this.description = catalog.description;
    this.sortOrder = catalog.sortOrder;
    this.isActive = catalog.isActive;
    this.pushStartTime = catalog.pushStartTime;
    this.pushEndTime = catalog.pushEndTime;
    this.categoryId = catalog.categoryId;
    this.createdAt = catalog.createdAt;
    this.updatedAt = catalog.updatedAt;
  }
}